import 'package:flutter/material.dart';

import '../contact/contact_define.dart';


//
// "avatar": "https://randomuser.me/api/portraits/men/19.jpg",
// "userId": 103,
// "userName": "mock",
// "date": "9-26",
// "infoMsg": "收藏了你的路线",
// "worksUrl": "https://randomuser.me/api/portraits/men/19.jpg"

class NotificationCell extends StatelessWidget {

  final String? avatar;
  final String userName;
  final String? date;
  final String? infoMsg;
  final String ? worksUrl;

  const NotificationCell({
    super.key,
    this.avatar,
    required this.userName,
    this.date,
    this.infoMsg,
    this.worksUrl,
  });

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 60,
      child: ListTile(
        leading: Container(
          width: 40,
          height: 40,
          decoration: BoxDecoration(
            // color: Colors.red,
            image: avatar == null
                ? null
                : DecorationImage(
              image: NetworkImage(avatar!),
              fit: BoxFit.cover,
            ),
            borderRadius: const BorderRadius.all(
              Radius.circular(4),
            ),
          ),
        ),
        title: _title(userName),
        trailing:Container(
          width: 40,
          height: 40,
          decoration: BoxDecoration(
            // color: Colors.red,
            image: worksUrl == null
                ? null
                : DecorationImage(
              image: NetworkImage(worksUrl!),
              fit: BoxFit.cover,
            ),
            borderRadius: const BorderRadius.all(
              Radius.circular(4),
            ),
          ),
        ) ,
      ),
    );
  }

  Widget _title(String name) {

    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(userName,style: TextStyle(fontSize: 18,fontWeight: FontWeight.bold),),
         Wrap(
           children: [
           Text(infoMsg!),
           Text(date!)
         ],)
      ],
    );
  }

}

